import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);


//公开路由表
const publicRoutes = [
  {
    path: '/',
    redirect: '/layout'
  },
  {
    path: '/layout',
    name: 'layout',
    component: () => import('../layout/index.vue'),
    redirect: '/dashboard',
    children: [
      {
        path: '/dashboard',
        name: 'dashboard',
        meta: { title: '首页', icon: 'el-icon-s-home' },
        component: () => import('../views/dashboard/index.vue'),
      },
    ],
  }
];


// 私有路由表
const privateRoutes = [
  {
    path: '/blog',
    name: 'blog',
    meta: { title: '博客管理', icon: 'el-icon-notebook-2' },
    component: () => import('../layout/index.vue'),
    redirect: '/blog/article',
    children: [
      {
        path: '/blog/article',
        name: 'article',
        meta: { title: '文章管理', icon: 'el-icon-notebook-1' },
        component: () => import('../views/article/index.vue'),
      },
      {
        path: '/blog/category',
        name: 'category',
        meta: { title: '分类管理', icon: 'el-icon-s-order' },
        component: () => import('../views/category/index.vue'),
      },
      {
        path: '/blog/label',
        name: 'label',
        meta: { title: '标签管理', icon: 'el-icon-collection-tag' },
        component: () => import('../views/label/index.vue'),
      },
    ]
  },
  {
    path: '/advert/index',
    component: () => import('../layout/index.vue'),
    redirect: '/advert/index',
    children: [
      {
        path: '/advert/index',
        name: 'advert',
        meta: { title: '广告管理', icon: 'el-icon-picture-outline-round' },
        component: () => import('../views/advert/index.vue'),
      },
    ]
  },
  {
    path: '/system',
    name: 'system',
    meta: { title: '系统管理', icon: 'el-icon-setting' },
    component: () => import('../layout/index.vue'),
    redirect: '/system/user',
    children: [
      {
        path: '/system/user',
        name: 'user',
        meta: { title: '用户管理', icon: 'el-icon-user-solid' },
        component: () => import('../views/user/index.vue'),
      },
      {
        path: '/system/role',
        name: 'role',
        meta: { title: '角色管理', icon: 'el-icon-coin' },
        component: () => import('../views/role/index.vue'),
      },
      {
        path: '/system/menu',
        name: 'menu',
        meta: { title: '菜单管理', icon: 'el-icon-menu' },
        component: () => import('../views/menu/index.vue'),
      },
    ]
  },
  {
    path: '/public',
    component: () => import('../layout/index.vue'),
    children: [
      {
        path: 'http://www.mengxuegu.com',
        meta: { title: '梦学谷官网', icon: 'el-icon-link' },
      },
    ]
  },
]

const router = new VueRouter({
  routes: [...publicRoutes, ...privateRoutes],
});

export default router;
